<?php

require_once("WorkoutUpdates/Model/WorkoutUpdateTitle.php");
require_once("WorkoutUpdates/Model/WorkoutUpdateComment.php");

class WorkoutUpdate
{
	/**
	*@var date
	*/		
	private $date;
	/**
	*@var string
	*/		
	private $title;
	/**
	*@var int 
	*/		
	private $userID;
	/**
	*@var string
	*/		
	private $comment;
	/**
	*@var int
	*/		
	private $updateID;
	/**
	*@var int 
	*/		
	private $workoutID;	

	/**
	*@param Title
	*@param Comment
	*@param int
	*@param int
	*@param date
	*@param int
	*/		
	private function __construct($title, $comment, $workoutID, $updateID = null, $date = null , $userID = null)
	{
		$this->title = $title;
		$this->comment = $comment;
		$this->workoutID = $workoutID;
		
		if($date != null)
		{
			$this->date = $date;
		}
		if($userID != null)
		{
			$this->userID = $userID;
		}

		if($updateID != null)
		{
			$this->updateID = $updateID;
		}
	}


	/**
	*@param string
	*@param string
	*@param int
	*@param int
	*@return WorkoutUpdate
	*/
	public static function createNewWorkoutUpdate($title, $comment, $workoutID, $workoutUpdate = null)
	{	
		return new WorkoutUpdate(new WorkoutUpdateTitle($title), 
								 new WorkoutUpdateComment($comment), 
								 $workoutID, $workoutUpdate);
	}

	/**
	*@param string
	*@param string
	*@param int
	*@param int
	*@param date
	*@param int
	*@return WorkoutUpdate
	*/
	public static function createWorkoutUpdateFromDatabase($title, $comment, $workoutID, $updateID, $date, $userID)
	{
		return new WorkoutUpdate(new WorkoutUpdateTitle($title),
		                         new WorkoutUpdateComment($comment), 
		                         $workoutID, $updateID, $date, $userID);
	}

	/**
	*@return date
	*/
	public function getDate()
	{
		return $this->date;
	}

	/**
	*@return int
	*/
	public function getUserID()
	{
		return $this->userID;
	}

	/**
	*@return int
	*/
	public function getUpdateID()
	{
		return $this->updateID;
	}

	/**
	*@return int
	*/
	public function getWorkoutID()
	{
		return $this->workoutID;
	}

	/**
	*@return string
	*/
	public function getTitle() 
	{
		return $this->title->getWorkoutTitle();
	}

	/**
	*@return string
	*/
	public function getComment()
	{
		return $this->comment->getWorkoutComment();
	}

	/**
    *@return bool
    **/
	public function CheckIfSameUserID($otherID)
	{
		var_dump($otherID); var_dump($this->getUserID());
		if($otherID == $this->getUserID()) 
		{								   
			return true;
		}
		return false;
	}

}